package com.qf.flash.ui.home;

import android.app.Activity;
import android.content.Intent;
import android.os.Parcelable;
import android.view.Gravity;
import android.view.View;
import android.widget.TextView;

import com.qf.flash.R;
import com.qf.flash.model.ScriptRoleBean;
import com.qf.flashlib.base.BaseActivity;
import com.zhouwei.mzbanner.MZBannerView;
import com.zhouwei.mzbanner.holder.MZHolderCreator;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 创建日期：2020/3/8 on 11:02
 * 描述:
 * 作者:戴旭东
 */
public class RolePagerActivity extends BaseActivity {


    @BindView(R.id.tv_top_title)
    TextView tvTopTitle;
    @BindView(R.id.banner_role)
    MZBannerView mBanner;

    public static void start(Activity activity, ArrayList<ScriptRoleBean> roleBeans, int pos) {
        Intent intent = new Intent(activity, RolePagerActivity.class);
        intent.putExtra("data", roleBeans);
        intent.putExtra("pos", pos);
        activity.startActivity(intent);
    }


    @Override
    protected int getLayoutId() {
        return R.layout.activity_role;
    }

    @Override
    protected void initViewAndData() {
        ArrayList<Parcelable> roleBeans = getIntent().getParcelableArrayListExtra("data");
        int pos = getIntent().getIntExtra("pos", 0);
        tvTopTitle.setText("角色详情");
        mBanner.setIndicatorRes(R.drawable.shape_indicator_unselect, R.drawable.shape_indicator_selected);
        mBanner.getIndicatorContainer().setGravity(Gravity.CENTER_VERTICAL);
        mBanner.setPages(roleBeans, (MZHolderCreator<RoleBannerViewHolder>) () -> new RoleBannerViewHolder());
        mBanner.getViewPager().setCurrentItem(pos);
    }


    @OnClick({R.id.tv_top_back, R.id.iv_close})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_top_back:
            case R.id.iv_close:
                finish();
                break;
        }
    }
}
